<template>
	<view class="home_container">
		<!-- banner -->
		<swiper-box :swiperList="swiperList"></swiper-box>
		<!-- <uni-link :href="zfbUrl" text="跳转支付宝"></uni-link> -->
		<!-- 公告 -->
		<notice :noticeList="noticeList"></notice>

		<!-- 产品tab -->
		<product-popup :productList="productList" @handleChooseTab="handleChooseTab" />

		<!-- 选择服务 -->
		<view class="home_service_box">
			<view
				class="service_product_box"
				v-for="(item, index) in topChooseList"
				:key="item.operator_id"
				:class="[isActive == item.operator_id ? 'service_product_box_active' : '']"
				@click="handlerService(item, index)"
			>
				<view class="product_img_box">
					<image :src="item.image" mode="" class="product_img"></image>
				</view>
				<view class="product_title">{{ item.name }}</view>
			</view>

			<!-- <view class="service_custom_box" @click="handlerCustom">
				<view class="custom_img_box">
					<image src="/static/home/icon-custom.png" mode="" class="custom_img"></image>
				</view>
				<view class="custom_title">联系客服</view>
			</view> -->
		</view>

		<!-- 秒返专区 -->
		<view class="return_seconds_box" @click="handleReturnSeconds(5)">
			<image :src="returnSeconds" mode="widthFix" class="return_seconds_img"></image>
		</view>

		<view class="hot_package_box">
			<view class="hot_package_line"></view>
			<view class="hot_package_title">
				{{ hotPackageTitle }}
			</view>
		</view>

		<view class="package_query_box">
			<view class="package_query_all" @click="handleBelong">
				<view class="package_query_name">
					{{ packageQueryObj.belongPlace ? packageQueryObj.belongPlace : '归属地' }}
				</view>
				<view class="package_query_img">
					<image src="/static/home/icon-arrow-down.png" mode="" class="query_img"></image>
				</view>
				<view class="">
					<!-- <u-input v-model="formClassify.belonging_place" type="select" :border="false"
								@click="showBelongingPlace = true" placeholder="请选择归属地" /> -->
					<u-select v-model="showBelongingPlace" :list="belongingPlaceList" @confirm="confirmBelonging" @cancel="cancelBelonging"></u-select>
				</view>
			</view>

			<view class="package_query_all" @click="handleTraffic">
				<view class="package_query_name">
					{{ packageQueryObj.trafficLimit ? packageQueryObj.trafficLimit : '流量额度' }}
					<span v-if="packageQueryObj.trafficLimit !== ''">G</span>
				</view>
				<view class="package_query_img">
					<image src="/static/home/icon-arrow-down.png" mode="" class="query_img"></image>
				</view>
				<view class="">
					<!-- <u-input v-model="formClassify.belonging_place" type="select" :border="false"
								@click="showBelongingPlace = true" placeholder="请选择归属地" /> -->
					<u-select v-model="showTrafficLimit" :list="trafficLimitList" @confirm="confirmTrafficLimit" @cancel="cancelTrafficLimit"></u-select>
				</view>
			</view>

			<view class="package_query_all" @click="handleCallDuration">
				<view class="package_query_name">
					{{ packageQueryObj.callDuration ? packageQueryObj.callDuration : '通话时长' }}
				</view>
				<view class="package_query_img">
					<image src="/static/home/icon-arrow-down.png" mode="" class="query_img"></image>
				</view>
				<view class="">
					<!-- <u-input v-model="formClassify.belonging_place" type="select" :border="false"
								@click="showBelongingPlace = true" placeholder="请选择归属地" /> -->
					<u-select v-model="showCallDuration" :list="callDurationList" @confirm="confirmCallDuration" @cancel="cancelCallDuration"></u-select>
				</view>
			</view>

			<view class="package_query_all" @click="handleClassify">
				<view class="package_query_name">
					{{ packageQueryObj.screen }}
				</view>
				<view class="package_query_img" style="width: 28rpx; height: 26rpx">
					<image src="/static/home/icon-screen.png" mode="" class="query_img"></image>
				</view>
			</view>
		</view>

		<!-- 套餐介绍 -->
		<view class="home_package_box" v-for="(item, index) in packageList" :key="item.id">
			<view class="home_package_all">
				<view class="package_top_img">
					<image :src="iconTopOneImg" mode="" class="top_img" v-if="index == 0"></image>
					<image :src="iconTopTwoImg" mode="" class="top_img" v-else-if="index == 1"></image>
					<image :src="iconTopThreeImg" mode="" class="top_img" v-else-if="index == 2"></image>
				</view>

				<view class="package_all_box" @click="handleShowAge(item, index)">
					<image :src="item.cover_img" mode="" class="package_all_img"></image>
				</view>
				<view class="package_all_con">
					<view class="package_title" @click="handleShowAge(item, index)">
						{{ item.name }}
					</view>
					<view class="pacakge_tip_box">
						<view
							class="pacakge_tip_all"
							:style="{ color: itemTag.font_color, border: `1px solid ${itemTag.background_color}` }"
							v-for="(itemTag, index) in item.tag_ids"
							:key="index"
						>
							{{ itemTag.tag }}
						</view>
					</view>
					<view class="package_flow_box" v-if="item.data_quota && item.call_duration" @click="handleShowAge(item, index)">
						<view class="package_flow">
							<view class="flow_title">{{ item.data_quota }}G</view>
							<view class="flow_name">流量</view>
						</view>

						<view class="flow_line"></view>

						<view class="package_flow">
							<view class="flow_title">{{ item.call_duration }}分钟</view>
							<view class="flow_name">通话</view>
						</view>
					</view>
				</view>
			</view>

			<view class="package_bottom_box">
				<view class="package_tip" @click="handleShowAge(item, index)">产品亮点：{{ item.bright ? item.bright : '无' }}</view>
				<view class="" style="display: flex; justify-content: space-between; align-items: center">
					<view class="package_commission" v-if="!userTokenNew">佣金：登录查看</view>
					<view class="package_commission" @click="handleShowAge(item, index)" v-else>
						佣金 ￥
						<span style="font-family: my-font">{{ item.yj }}</span>
					</view>

					<view class="package_btn_box">
						<!-- || !userWxOpenidNew -->
						<view v-if="!userToken">
							<button open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber" class="package_btn_phone">立即推广</button>
						</view>

						<view class="package_btn" @click="handlerPackage(item, index)" v-else>立即推广</view>
					</view>
				</view>
			</view>

			<view class="home_package_other" v-if="isShowAge == item.id">
				<view class="handle_age_box">
					<view class="age_icon_box">
						<image src="/static/home/icon-commission.png" mode="" class="age_icon"></image>
					</view>

					<view class="age_title">佣金政策：{{ item.yjzc }}</view>
				</view>
				<view class="handle_age_box">
					<view class="age_icon_box">
						<image :src="cardIcon" mode="" class="age_icon"></image>
					</view>
					<view class="age_title">办理年龄: {{ item.min_age }}-{{ item.max_age }}岁</view>
				</view>

				<view class="handle_age_box">
					<view class="age_icon_box">
						<image :src="addressIcon" mode="" class="age_icon"></image>
					</view>
					<view class="age_title" v-if="item.noly_delivery_area">只发货地址: {{ item.noly_delivery_area }}</view>
					<view class="age_title" v-else>不发货地址: {{ item.sensitive_areas }}</view>
				</view>
			</view>
		</view>

		<!-- 到底啦 -->
		<view class="bottom_box" v-if="pageObj.pageNow == total">----- 暂无更多数据 -----</view>

		<!-- 分享弹窗 -->
		<u-popup v-model="showPopupShare" mode="center" border-radius="12" z-index="1">
			<view class="popup_share_box">
				<view class="share_img_box">
					<!-- <canvas style="width: 100%;height:100%;" canvas-id="code">
						<img :src="promotionImg" alt="" class="share_img" />
					</canvas> -->
					<image :src="promotionImg" mode="" class="share_img" :show-menu-by-longpress="true"></image>
				</view>
				<view class="share_btn_box">
					<view class="share_btn_all" @click="handleShare('保存本地')">
						<view class="share_btn_img">
							<image src="/static/home/icon-save.png" mode="" class="btn_img"></image>
						</view>
						<view class="share_btn_title">保存本地</view>
					</view>

					<view class="share_btn_all" @click="handleShare('复制链接')">
						<view class="share_btn_img">
							<image src="/static/home/icon-copy.png" mode="" class="btn_img"></image>
						</view>
						<view class="share_btn_title">复制链接</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!-- 通知弹窗 -->
		<u-popup v-model="showNotify" mode="center" border-radius="12" close-icon-color="#000" class="popup_notify_all">
			<view class="popup_notify_box">
				<u-parse :html="notifyMsg"></u-parse>
			</view>
		</u-popup>

		<!-- 客服按钮 -->
		<liu-drag-button @click="handlerCustom">
			<view class="custom_img_box">
				<image :src="customNewImg" mode="widthFix" class="custom_img"></image>
			</view>
		</liu-drag-button>

		<!-- 套餐分类弹窗 -->
		<u-popup v-model="showClassify" mode="center" border-radius="12" :closeable="true" close-icon-color="#000" style="margin: 0 20rpx">
			<view class="classify_popup_box">
				<view class="classify_popup_title">查询条件</view>

				<!-- <view class="classify_title">
					可否选号
				</view>
				<view class="select_box">
					<u-input v-model="formClassify.is_choose_number" type="select" :border="false"
						@click="isChooseNumber = true" placeholder="请选择可否选号" />
					<u-select v-model="isChooseNumber" :list="selectNumberList"
						@confirm="confirmChooseNumber"></u-select>
				</view> -->

				<view class="classify_title">首充金额</view>
				<view class="">
					<view class="select_box">
						<u-input v-model="packageQueryObj.firstRechargeAmount" type="select" :border="false" placeholder="请选择首充金额" @click="handleChooseFirstRecharge" />
						<u-select v-model="showFirstRecharge" :list="firstRechargeList" @confirm="confirmFirstRecharge"></u-select>
					</view>
				</view>

				<view class="classify_title">月租</view>
				<view class="">
					<view class="select_box">
						<u-input v-model="packageQueryObj.monthlyRent" type="select" :border="false" placeholder="请选择月租" @click="handleChooseMonth" />
						<u-select v-model="showMonthlyRent" :list="monthlyRentList" @confirm="confirmMonthlyRent"></u-select>
					</view>
				</view>

				<view class="classify_btn_box">
					<view class="classify_reset_btn" @click="handleRefresh">
						重置
						<!-- <u-button type="warning" @click="handleRefresh">重置</u-button> -->
					</view>
					<view class="classify_sure_btn" @click="handleSureClassify">
						确定
						<!-- <u-button type="primary" @click="handleSureClassify">确定</u-button> -->
					</view>
				</view>
			</view>
		</u-popup>

		<!-- 客服弹窗 -->
		<u-popup v-model="showCustom" mode="center" border-radius="12" :closeable="true" close-icon-color="#000">
			<view class="popup_custom_box">
				<image :src="customObj" mode="widthFix" class="popup_custom_img" :show-menu-by-longpress="true"></image>
				<button open-type="contact" show-message-card session-from send-message-path send-message-title v-if="isShowCustomUrl">在线客服</button>
			</view>
		</u-popup>
		<!-- 客服弹窗 -->
		<u-popup v-model="showCustom" mode="center" border-radius="12" :closeable="true" close-icon-color="#000">
			<view class="popup_custom_box">
				<image :src="customObj" mode="widthFix" class="popup_wx_img" :show-menu-by-longpress="true"></image>
			</view>
		</u-popup>

		<!-- 名下手机号弹窗 -->
		<u-popup v-model="showNamePhone" mode="center" width="680" border-radius="12">
			<view class="popup_name_box">
				<view class="popup_name_title">一证通查 便携百宝箱</view>

				<view class="popup_option_title">(1)查询名下电话卡数量</view>
				<view class="popup_option_con" @click="handleQuery('1')">点击查询</view>

				<view class="popup_option_title">(2)运营商官方渠道查询订单</view>
				<view class="popup_option_con">
					<span @click="handleQuery('2')">中国电信</span>
					、
					<span @click="handleQuery('2')">中国联通</span>
					、
					<span @click="handleQuery('2')">中国移动</span>
				</view>

				<view class="popup_option_title">(3)运营商官方渠道撤销订单</view>
				<view class="popup_option_con">
					<span @click="handleQuery('3')">中国电信</span>
					、
					<span @click="handleQuery('3')">中国联通</span>
				</view>
			</view>
		</u-popup>

		<!-- 关注公众号弹窗 -->
		<u-popup v-model="showOfficialAccount" mode="center" width="680" border-radius="12">
			<view class="popup_official_box">
				<image :src="officialAccountImg" mode="widthFix" :show-menu-by-longpress="true"></image>
			</view>
			<view class="popup_official_title">请先关注公众号</view>
		</u-popup>

		<!-- 产品知识库弹窗 -->
		<u-popup v-model="showKnowledgeBase" mode="center" :closeable="true" close-icon-color="#000" border-radius="12" width="680" height="1000">
			<view class="" style="padding: 90rpx 20rpx 50rpx">
				<u-parse :html="knowledgeDetail"></u-parse>
			</view>
		</u-popup>

		<!-- 弹窗展示上加下信息 popupDetailList.length !== 0 && shouldShowContent-->
		<u-popup v-model="isShowDetailList" mode="center" :closeable="true" close-icon-color="#fff" border-radius="12" width="650" height="850" @close="handleCloseDetailList">
			<view class="popup_detail_img_box">
				<view class="popup_detail_msg">
					<view class="popup_detail_msg_box" v-for="(item, index) in popupDetailList" :key="index">
						<view class="popup_detail_title">{{ item.title }}:</view>
						<view class="popup_detail_content">
							<u-parse :html="item.content"></u-parse>
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!-- 邀请好友办卡弹窗 -->
		<invite-popup ref="refInvitePopup" @handleCheckInvite="handleCheckInvite" @handleCloseInvite="handleCloseInvite" />

		<!-- 靓号产品弹窗 -->
		<beautiful-number ref="refBeautifulNumber" :beautifulNum="beautifulNum" />

		<!-- 靓号提示弹窗 -->
		<u-popup v-model="showBeautifulPopup" mode="center" width="650">
			<view class="beautiful_popup_box">
				<view class="beautiful_title">温馨提示</view>

				<view class="beautiful_content" v-html="partnerReminder"></view>

				<view class="beautiful_btn" @click="handleKnow">我已知晓</view>
			</view>
		</u-popup>

		<!-- 随身wifi弹窗 -->
		<wifi-product-share ref="refWiFiShare" :wifiPoster="wifiPoster" @handleCloseWifiShare="handleCloseWifiShare" />
		<!-- 宽带产品立即推广海报弹窗 -->
		<broadband-product-share ref="refBroadbandShare" :broadbandPoster="broadbandPoster" @handleClosebroadbandShare="handleClosebroadbandShare" />
	</view>
</template>

<script>
// import VConsole from 'vconsole';
import wx from 'weixin-js-sdk';
import imageUrl from '@/utils/imgUrl.js';
import SwiperBox from '@/pages/index/components/swiperBox.vue';
import InvitePopup from './components/invitePopup.vue';
import Notice from '@/pages/index/components/notice.vue';
import ProductPopup from './components/productPopup.vue';
import BeautifulNumber from './components/beautifulNumber.vue';
import WifiProductShare from './components/wifiProductShare.vue';
import provinceList from '@/utils/province.js';
import parseQueryString from '@/utils/interceptUrl.js';
import broadbandProductShare from './components/broadbandProductShare.vue';
export default {
	components: {
		SwiperBox,
		Notice,
		InvitePopup,
		ProductPopup,
		BeautifulNumber,
		WifiProductShare,
		broadbandProductShare
	},
	data() {
		return {
			customNewImg: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/6683694ff185a_1719888207.png',
			zfbUrl: '',
			// zfbUrl: 'https://ds.alipay.com/?scheme=alipays://platformapi/startapp?ap0=2021003165613385&page=pages/index/index?applyId%3D33509',
			// zfbUrl: 'https://item.jd.com/10033505098303.html#crumb-wrap',

			// 公告数据
			noticeList: [],
			// 顶部选项数据
			topChooseList: [],

			// 套餐数据
			packageList: [],
			packageType: 2,
			maskTitle: '',
			bannerImg: '',
			swiperList: [],
			isActive: '',
			packageId: '',
			promotionImg: '',
			shareObj: {},
			packageDetailObj: {},
			showGenerate: false,
			packageLink: '',
			showPopupShare: false,
			showNotify: false,
			notifyMsg: '',
			isWeixin: false,
			showClassify: false,
			belongingPlaceList: [],
			showBelongingPlace: false,
			isChooseNumber: false,
			formClassify: {
				belonging_place: '',
				data_quota: 0,
				call_duration: 0,
				is_choose_number: '',
				first_recharge_amount: 0,
				monthly_rent: 0
			},
			selectNumberList: [
				{
					value: '0',
					label: '不选号'
				},
				{
					value: '1',
					label: '选号'
				}
			],
			isShowAge: null,
			pageObj: {
				pageNow: 1,
				pageSize: 10
			},
			total: null,
			pageNum: 1,
			hotPackageTitle: '',
			promotionSahreImg: '',
			showCustom: false,
			customObj: {},
			promotionSahreUrl: '',
			fileUrl: '',
			fileType: '',
			share: {
				title: '',
				path: '', //页面路径
				imageUrl: '' //页面图，可自定义
			},
			// 控制客服返回url还是图片
			isShowCustomUrl: false,
			packageQueryObj: {
				belongPlace: '',
				trafficLimit: '',
				callDuration: '',
				screen: '筛选',
				firstRechargeAmount: '',
				monthlyRent: ''
			},
			showTrafficLimit: false,
			trafficLimitList: [
				{
					value: '0-50',
					label: '0-50'
				},
				{
					value: '50-100',
					label: '50-100'
				},
				{
					value: '100-150',
					label: '100-150'
				},
				{
					value: '150-200',
					label: '150-200'
				},
				{
					value: '200-300',
					label: '200-300'
				},
				{
					value: '300-400',
					label: '300-400'
				},
				{
					value: '400-500',
					label: '400-500'
				}
			],
			showCallDuration: false,
			callDurationList: [
				{
					value: '0-300',
					label: '0-300'
				},
				{
					value: '300-500',
					label: '300-500'
				},
				{
					value: '500-1000',
					label: '500-1000'
				}
			],
			showFirstRecharge: false,
			firstRechargeList: [
				{
					value: '0-50',
					label: '0-50'
				},
				{
					value: '50-100',
					label: '50-100'
				},
				{
					value: '100-150',
					label: '100-150'
				}
			],
			showMonthlyRent: false,
			monthlyRentList: [
				{
					value: '0-50',
					label: '0-50'
				},
				{
					value: '50-100',
					label: '50-100'
				},
				{
					value: '100-150',
					label: '100-150'
				}
			],
			showNamePhone: false,
			token: '',
			userId: '',
			isSubscribe: '', // 是否关注公众号
			showOfficialAccount: false,
			officialAccountImg: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/lunbo_image/660ccdfd97e61_1712115197.jpg',
			userToken: '',
			userTokenNew: '',
			showKnowledgeBase: false,
			knowledgeId: '',
			knowledgeDetail: '',
			popupDetailList: [],
			showPopupStatus: false,
			lastVisited: null, // 存储上次访问的日期
			messagePopupImg: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/6653fc4f6320a_1716780111.png',
			userWxOpenidNew: '',
			isShowDetailList: false,
			iconTopOneImg: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/669085f7f3aeb_1720747511.png',
			iconTopTwoImg: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66908624bdbc3_1720747556.png',
			iconTopThreeImg: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/669086305ced5_1720747568.png',
			// 秒返专区图片
			returnSeconds: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66a9a97bea11d_1722395003.png',
			sceneNumber: '',
			// 产品列表
			productList: [
				{
					id: 0,
					name: '号卡产品',
					img: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66c97eb6d20b6_1724481206.png'
				},
				{
					id: 1,
					name: '靓号产品',
					img: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66c97ec79abba_1724481223.png'
				},
				{
					id: 2,
					name: '随身WIFI',
					img: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66c97eda6e18e_1724481242.png'
				},
				{
					id: 3,
					name: '宽带产品',
					img: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66c97ee9501c3_1724481257.png'
				},
				{
					id: 4,
					name: '权益',
					img: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66c97ef50408d_1724481269.png'
				}
			],
			beautifulNum: {},

			showBeautifulPopup: false,
			wifiPoster: {},
			partnerReminder: '',
			broadbandPoster: {},
			addressIcon: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66f7a62b11722_1727505963.png',
			cardIcon: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/wechat_xcx/66f7a68fde7ba_1727506063.png'
		};
	},
	onShow() {
		this.userTokenNew = uni.getStorageSync('h5-token');
		this.userToken = uni.getStorageSync('h5-token');
		this.userWxOpenidNew = uni.getStorageSync('userWxOpenid');
		if (this.pageObj.pageNow == this.total) {
			return;
		}
		// this.getHkMsg()
		// this.getBanner()
		// this.getPackageType()
		if (!uni.getStorageSync('h5-token')) {
			this.getAgentPackageAllNotk();
		} else {
			this.getPackageList();
		}
		// this.getIpAddress()
		this.belongingPlaceList = provinceList;
		this.belongingPlaceList.forEach((item) => {
			item.value = item.code;
			item.label = item.name;
		});
		this.imgUrlNew = imageUrl;
	},
	onPullDownRefresh() {
		uni.startPullDownRefresh();
	},
	onLoad(options) {
		// this.getInvitePopup()
		if (options.token) {
			this.token = options.token;
			this.userId = options.user_id;
			uni.setStorageSync('h5-token', this.token);

			this.getUserInfo(this.userId);
		}
		this.getLayerShow();
		if (options.scene) {
			const scene = decodeURIComponent(options.scene);
			this.sceneNumber = scene;
			this.getMiniProgramScene();
		}
		// else {

		// }

		this.addVisitCountClick();
	},
	// 分享好友
	onShareAppMessage(res) {
		if (res.from === 'button') {
		}
		return {
			title: this.share.title,
			path: this.share.path,
			imageUrl: this.share.imageUrl,
			success(res) {
			},
			fail(res) {
			}
		};
	},

	// 分享朋友圈
	onShareTimeline(res) {
		return {
			title: this.share.title,
			path: this.share.path,
			imageUrl: this.share.imageUrl,
			success(res) {
				uni.showToast({
					title: '分享成功',
					icon: 'success'
				});
			},
			fail(err) {
				uni.showToast({
					title: '分享失败',
					icon: 'error'
				});
			}
		};
	},
	onReachBottom() {
		if (this.pageObj.pageNow < this.total) {
			this.pageObj.pageNow++;
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
			// this.getIpAddress()
			// this.getPackageList()
		} else if (this.pageObj.pageNow == this.total) {
			return;
		}
	},
	computed: {
		// 判断当天只展示一次，第二天再次展示
		shouldShowContent() {
			// 获取当前日期
			const currentDate = new Date().toISOString().split('T')[0];

			// 尝试从localStorage中获取上次访问的日期
			try {
				this.lastVisited = uni.getStorageSync('lastVisited');
			} catch (error) {
				// 处理可能的错误（例如，localStorage被禁用）
				console.error('Error accessing localStorage:', error);
			}

			// 如果上次访问的日期不存在或与当前日期不同，则展示内容
			if (!this.lastVisited || this.lastVisited !== currentDate) {
				// 更新localStorage中的日期为当前日期
				uni.setStorageSync('lastVisited', currentDate);
				return true; // 展示内容
			}

			// 如果上次访问的日期与当前日期相同，则不展示内容
			return false;
		}
	},
	methods: {
		// 关闭随身wifi弹窗
		handleCloseWifiShare() {
			this.$refs.refWiFiShare.isShowWifiShare = false;
		},

		// 随身wifi海报
		getWifiPoster() {
			this.$request('/api/getIotGoodsSmallShopPoster', {}, 'GET').then((res) => {
				uni.hideLoading();
				if (res.code == 1) {
					this.wifiPoster = res;
				} else {
					uni.showToast({
						title: '获取随身WIFI海报失败',
						icon: 'none'
					});
					return;
				}
			});
		},

		// 宽带产品海报
		getBroadbandPoster() {
			this.$request('/api/getBroadbandSmallShopPoster', { type: 1, poster_id: 11 }, 'GET').then((res) => {
				uni.hideLoading();
				if (res.code == 1) {
					this.broadbandPoster = res;
				} else {
					uni.showToast({
						title: '获取随身WIFI海报失败',
						icon: 'none'
					});
					return;
				}
			});
		},

		// 访问统计接口
		addVisitCountClick() {
			this.$request(
				'/addVisitCountClick',
				{
					tab: 'index'
				},
				'GET'
			).then((res) => {});
		},

		// 查询微信小程序场景值接口
		getMiniProgramScene() {
			uni.request({
				url: 'https://saler.jkcae.com/app/getMiniProgramScene?id=' + this.sceneNumber,
				method: 'GET',
				success: (res) => {
					if (res.data.code == 1) {
						let llgSceneDetail = parseQueryString(res.data.data);
						this.sceneObj = llgSceneDetail;
						uni.setStorageSync('llgSceneObj', llgSceneDetail.is_llg);
					} else {
						uni.showToast({
							title: '查询失败',
							icon: 'none'
						});
						return;
					}
				}
			});
		},

		// 关闭上下架通知弹窗
		handleCloseDetailList() {
			this.getInvitePopup();
		},

		// 展示邀请好友办卡弹窗
		getInvitePopup() {
			this.$refs.refInvitePopup.isShowInvite = true;
		},

		// 点击邀请好友办卡弹窗的查看
		handleCheckInvite() {
			if (!this.userTokenNew) {
				uni.reLaunch({
					url: '/pages/login/login'
				});
			} else {
				return;
			}
		},

		// 关闭邀请好友弹窗
		handleCloseInvite() {
			this.$refs.refInvitePopup.isShowInvite = false;
		},

		// 展示弹窗接口
		getLayerShow() {
			const that = this;
			this.$request('/getLayerShow', {}, 'GET').then((res) => {
				if (res.code == 1) {
					this.popupDetailList = res.data;
					this.popupDetailList.forEach((item) => {
						const now = new Date();
						const start = new Date(item.start_time);
						const end = new Date(item.end_time);
						item.isShow = now >= start && now < end;
					});
					if (this.popupDetailList.length !== 0 && this.shouldShowContent) {
						that.isShowDetailList = true;
					} else {
						that.getInvitePopup();
					}
				} else {
					return;
				}
			});
		},

		// 是否需要关注公众号
		getFxuserIsFollow() {
			this.$request('/api/getFxuserIsFollow', {}, 'GET').then((res) => {
				if (res.code == 1) {
					if (res.data == 0) {
						// 不用关注
						uni.showLoading({
							title: '正在加载中'
						});

						// this.getOncePackageLink()
						this.getOncePackageShareImg();
						this.showPopupShare = true;
					} else {
						// 要关注
						this.getFxuserIsSubscribe();
					}
				} else {
					uni.showToast({
						title: '获取失败',
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取套餐知识库接口
		getPackageKnowledge() {
			this.$request('/getPackageKnowledge?package_id=' + this.knowledgeId, {}, 'GET').then((res) => {
				if (res.code == 1) {
					this.knowledgeDetail = res.data;
					if (this.knowledgeDetail) {
						this.showKnowledgeBase = true;
					}
				} else {
					uni.showToast({
						title: '获取套餐知识库失败',
						icon: 'none'
					});
					return;
				}
			});
		},

		// 通过ip获取定位
		getIpAddress() {
			const that = this;
			uni.request({
				url: 'https://information.flow.haokazhijia.net/api/getQqIp',
				method: 'POST',
				success: (res) => {
					// this.city = res.data.result.ad_info.province + '-' + res.data.result.ad_info.city +
					// 	'-' + res.data.result.ad_info.district
					this.packageQueryObj.belongPlace = res.data.result.ad_info.province;
					if (this.userToken) {
						this.getPackageList();
					} else {
						this.getAgentPackageAllNotk();
					}
				}
			});
		},

		// 获取是否关注公众号接口
		getFxuserIsSubscribe(val) {
			const that = this;
			this.$request('/api/getFxuserIsSubscribe', {}, 'GET').then((res) => {
				if (res.code == 1) {
					this.isFollow = res.data;
					if (!uni.getStorageSync('h5-token')) {
					} else {
						if (this.isFollow == false) {
							that.showOfficialAccount = true;
						} else {
							if (this.packageId) {
								uni.showLoading({
									title: '正在加载中'
								});
								// this.getOncePackageLink()
								this.getOncePackageShareImg();
								// 判断是否有packageId
								this.showPopupShare = true;
							}
						}
					}
				} else {
					// uni.showToast({
					// 	title: '获取是否关注公众号失败',
					// 	icon: 'none'
					// })
					return;
				}
			});
		},

		// 获取用户信息
		getUserInfo(val) {
			const that = this;
			this.$request('/api/getFxuserLoginInfo', {}, 'GET').then((res) => {
				if (res.code == 1) {
					this.personMsgObj = res.data;
					uni.setStorageSync('userInfo', this.personMsgObj);
					uni.login({
						provider: 'weixin', //使用微信登录
						success: function (loginRes) {
							that.xcxGetUserInfo(loginRes.code, res.data.phone);
						}
					});
					this.getFxuserIsSubscribe();
				} else {
					uni.showToast({
						title: '查询用户信息失败',
						icon: 'none'
					});
					return;
				}
			});
		},

		// 点击查询等按钮
		handleQuery(val) {
			if (val == '1') {
				// location.href = 'https://getsimnum.caict.ac.cn/m/#/'
				uni.navigateTo({
					url: '/pages/index/webview/webview?url=' + 'https://getsimnum.caict.ac.cn/m/#/'
				});
			} else if (val == '2') {
				uni.navigateTo({
					url: '/pages/index/webview/webview?url=' + 'https://dev.coc.10086.cn/coc/web/coc2020/cardqueryorder/'
				});
			} else if (val == '3') {
				uni.navigateTo({
					url: '/pages/index/webview/webview?url=' + 'https://m.10010.com/myorder/'
				});
			}
		},

		// 首充金额确定
		confirmFirstRecharge(e) {
			this.packageList = [];
			this.packageQueryObj.firstRechargeAmount = e[0].value;
			if (!uni.getStorageSync('h5-token')) {
				this.getAgentPackageAllNotk();
			} else {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			}
		},

		// 首充金额显示下拉
		handleChooseFirstRecharge() {
			this.showFirstRecharge = true;
		},

		// 月租确定
		confirmMonthlyRent(e) {
			this.packageList = [];
			this.packageQueryObj.monthlyRent = e[0].value;
			if (!uni.getStorageSync('h5-token')) {
				this.getAgentPackageAllNotk();
			} else {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			}
		},

		// 月租显示下拉
		handleChooseMonth() {
			this.showMonthlyRent = true;
		},

		// 选择归属地
		handleBelong() {
			this.showBelongingPlace = true;
		},

		// 选择流量额度
		handleTraffic() {
			this.showTrafficLimit = true;
		},

		// 选择通话时长
		handleCallDuration() {
			this.showCallDuration = true;
		},

		// 判断是否是微信浏览器打开
		isWechat() {
			return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === 'micromessenger';
		},

		saveImg() {
			let that = this;
			//获取授权列表，查看是否授权写入相册权限
			uni.downloadFile({
				url: that.promotionSahreImg,
				success: (res) => {
					if (res.statusCode === 200) {
						that.saveimgtoAlbum(res.tempFilePath);
					} else {
						uni.showToast({
							title: '保存失败',
							icon: 'error',
							duration: 2000
						});
					}
				}
			});
		},
		saveimgtoAlbum(imgurl) {
			//图片保存到本地
			let that = this;
			uni.showLoading();
			uni.saveImageToPhotosAlbum({
				filePath: imgurl,
				success: function (data) {
					uni.hideLoading();
					uni.showToast({
						title: '保存成功',
						icon: 'success',
						duration: 2000
					});
				},
				fail: function (err) {
					uni.hideLoading();
					if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
						uni.openSetting({
							success(settingdata) {
								if (settingdata.authSetting['scope.writePhotosAlbum']) {
									uni.showToast({
										title: '您已授权成功，请重新保存海报',
										icon: 'success',
										duration: 2000
									});
								} else {
									uni.showToast({
										title: '尚未授权，无法保存海报',
										icon: 'none',
										duration: 2000
									});
								}
							}
						});
					}
				},
				complete(res) {}
			});
		},
		// 分享
		handleShare(val) {
			const that = this;
			if (val == '保存本地') {
				that.saveImg();
			} else if (val == '复制链接') {
				uni.setClipboardData({
					data: that.promotionSahreUrl,
					success: (res) => {
						uni.showToast({
							title: '复制链接成功',
							icon: 'none'
						});
					}
				});
			} else if (val == '微信好友') {
				let originalUrl = that.promotionSahreUrl.split('?')[1];
				// let originalUrl = that.promotionSahreUrl
				let url = parseQueryString(originalUrl);
				let packageId = url.package_id;
				let agentId = url.agent_id;
				let fxuserId = url.fxuser_id;
				let level = url.level;
				let agentProId = url.agent_pro_id;
				// 换成我的小店页面
				that.share.path =
					'/pages/quertDetail/quertDetail?package_id=' +
					packageId +
					'&agent_id=' +
					agentId +
					'&fxuser_id=' +
					fxuserId +
					'&level=' +
					level +
					'&agent_pro_id=' +
					agentProId;
			} else if (val == '朋友圈') {
				let originalUrl = that.promotionSahreUrl.split('?')[1];
				let url = parseQueryString(originalUrl);
				let packageId = url.package_id;
				let agentId = url.agent_id;
				let fxuserId = url.fxuser_id;
				let level = url.level;
				let agentProId = url.agent_pro_id;
				// 换成我的小店页面
				this.share.path =
					'/pages/quertDetail/quertDetail?package_id=' +
					packageId +
					'&agent_id=' +
					agentId +
					'&fxuser_id=' +
					fxuserId +
					'&level=' +
					level +
					'&agent_pro_id=' +
					agentProId;
				uni.showToast({
					title: '请点击右上角三个点进行分享朋友圈',
					icon: 'none'
				});
			}
		},

		// handlerZfb() {
		// 	// #ifdef H5

		// 	// #endif
		// 	const url = `https://ds.alipay.com/?scheme=` + encodeURIComponent(
		// 		"alipays://platformapi/startapp?appId=2021003165613385&page=pages/index/index?applyId%3D33506"
		// 	)
		// 	uni.setStorageSync('webUrl', url)
		// 	uni.navigateTo({
		// 		url: '/pages/index/webview/webview?urls=' + encodeURIComponent(JSON.stringify(url))
		// 	})
		// },

		// 点击分类浮动按钮
		handleClassify() {
			this.showClassify = true;
		},

		// 选择归属地确定
		confirmBelonging(e) {
			this.packageList = [];
			this.formClassify.belonging_place = e[0].label;
			this.packageQueryObj.belongPlace = e[0].label;
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 选择归属地取消
		cancelBelonging(e) {
			this.packageQueryObj.belongPlace = '';
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 选择流量额度确定
		confirmTrafficLimit(e) {
			this.packageList = [];
			this.packageQueryObj.trafficLimit = e[0].value;
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 选择流量额度取消
		cancelTrafficLimit(e) {
			this.packageQueryObj.trafficLimit = '';
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 选择通话时长确定
		confirmCallDuration(e) {
			this.packageList = [];
			this.packageQueryObj.callDuration = e[0].value;
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 选择通话时长取消
		cancelCallDuration(e) {
			this.packageQueryObj.callDuration = '';
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 可否选号确定
		confirmChooseNumber(e) {
			this.formClassify.is_choose_number = e[0].label;
		},

		// 分类弹窗-重置
		handleRefresh() {
			// this.packageQueryObj.belongPlace = ''
			// this.packageQueryObj.trafficLimit = ''
			// this.packageQueryObj.callDuration = ''
			this.packageQueryObj.firstRechargeAmount = '';
			this.packageQueryObj.monthlyRent = '';
			this.showClassify = false;
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 分类弹窗-确定
		handleSureClassify() {
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
			this.showClassify = false;
		},

		// 获取套餐分类
		getPackageType() {
			this.$request(
				'/getTypeListFront',
				{
					status: '0'
				},
				'GET'
			).then((res) => {
				if (res.code == 1) {
					res.data.push({
						image: 'https://file-1314054542.cos.ap-shanghai.myqcloud.com/cos_file/package_type_image/661df2f0296bd_1713238768.png',
						name: '全部',
						operator_id: ''
					});
					this.topChooseList = res.data.reverse();
					// this.topChooseList.forEach((item, index) => {
					// 	if (item.name == '秒返专区') {
					// 		this.topChooseList.splice(index, 1);
					// 	}
					// });
					this.hotPackageTitle = this.topChooseList[0].name;
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取通知
		getHkMsg() {
			this.$request(
				'/getHkMsg',
				{
					id: uni.getStorageSync('userInfo').id ? uni.getStorageSync('userInfo').id : ''
				},
				'POST'
			).then((res) => {
				if (res.code == 1) {
					this.notifyMsg = res.data.msg;
					this.showNotify = true;
				} else {
					this.showNotify = false;
				}
			});
		},

		// 获取banner
		getBanner() {
			this.swiperList = [];
			this.$request('/getLbListFront', {}, 'GET').then((res) => {
				if (res.code == 1) {
					res.data.forEach((item, index) => {
						if (item.type == 1) {
							this.swiperList.push({
								image: item.img,
								id: item.id,
								url: item.url
							});
						}
						if (item.id == 20) {
							this.swiperList.splice(index, 1);
						}
					});
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取公告
		getRollMessageList() {
			this.noticeList = [];
			this.$request('/api/getRollMessageList', {}, 'GET').then((res) => {
				if (res.code == 1) {
					res.data.forEach((item) => {
						this.noticeList.push(item.content);
					});
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取套餐列表-无token
		getAgentPackageAllNotk() {
			this.$request(
				'/getAgentPackageAllNotk',
				{
					page_now: this.pageObj.pageNow,
					page_size: this.pageObj.pageSize,
					operator_id: this.isActive,
					belonging_place: this.packageQueryObj.belongPlace,
					data_quota_min: this.packageQueryObj.trafficLimit ? this.packageQueryObj.trafficLimit.split('-')[0] : '',
					data_quota_max: this.packageQueryObj.trafficLimit ? this.packageQueryObj.trafficLimit.split('-')[1] : '',
					call_duration_min: this.packageQueryObj.callDuration ? this.packageQueryObj.callDuration.split('-')[0] : '',
					call_duration_max: this.packageQueryObj.callDuration ? this.packageQueryObj.callDuration.split('-')[1] : '',
					// is_choose_number: this.formClassify.is_choose_number, // 可否选号
					first_recharge_amount_min: this.packageQueryObj.firstRechargeAmount ? this.packageQueryObj.firstRechargeAmount.split('-')[0] : '',
					first_recharge_amount_max: this.packageQueryObj.firstRechargeAmount ? this.packageQueryObj.firstRechargeAmount.split('-')[1] : '',
					monthly_rent_min: this.packageQueryObj.monthlyRent ? this.packageQueryObj.monthlyRent.split('-')[0] : '',
					monthly_rent_max: this.packageQueryObj.monthlyRent ? this.packageQueryObj.monthlyRent.split('-')[1] : ''
				},
				'GET'
			).then((res) => {
				if (res.code == 1) {
					// res.data.forEach(item => {
					// 	this.packageList.push(item)
					// })
					this.getBanner();
					this.getPackageType();
					res.data.forEach((item) => {
						if (item.is_upload == '1') {
							this.packageList.push(item);
						} else {
							return;
						}
					});
					// let arr = []
					// res.data.forEach(item => {
					// 	if (item.is_upload == '1') {
					// 		arr.push(item)
					// 	} else {
					// 		return
					// 	}
					// })
					// this.packageList = arr
					this.total = res.page_info.page_count;
					uni.stopPullDownRefresh();
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取套餐列表-token
		getPackageList() {
			this.$request(
				'/api/getProductCenter',
				{
					page_now: this.pageObj.pageNow,
					page_size: this.pageObj.pageSize,
					operator_id: this.isActive,
					belonging_place: this.packageQueryObj.belongPlace,
					data_quota_min: this.packageQueryObj.trafficLimit ? this.packageQueryObj.trafficLimit.split('-')[0] : '',
					data_quota_max: this.packageQueryObj.trafficLimit ? this.packageQueryObj.trafficLimit.split('-')[1] : '',
					call_duration_min: this.packageQueryObj.callDuration ? this.packageQueryObj.callDuration.split('-')[0] : '',
					call_duration_max: this.packageQueryObj.callDuration ? this.packageQueryObj.callDuration.split('-')[1] : '',
					// is_choose_number: this.formClassify.is_choose_number, // 可否选号
					first_recharge_amount_min: this.packageQueryObj.firstRechargeAmount ? this.packageQueryObj.firstRechargeAmount.split('-')[0] : '',
					first_recharge_amount_max: this.packageQueryObj.firstRechargeAmount ? this.packageQueryObj.firstRechargeAmount.split('-')[1] : '',
					monthly_rent_min: this.packageQueryObj.monthlyRent ? this.packageQueryObj.monthlyRent.split('-')[0] : '',
					monthly_rent_max: this.packageQueryObj.monthlyRent ? this.packageQueryObj.monthlyRent.split('-')[1] : ''
				},
				'GET'
			).then((res) => {
				if (res.code == 1) {
					this.getBanner();
					this.getPackageType();
					res.data.forEach((item) => {
						if (item.is_upload == '1') {
							this.packageList.push(item);
						} else {
							return;
						}
					});
					// let arr = []
					// res.data.forEach(item => {
					// 	if (item.is_upload == '1') {
					// 		arr.push(item)
					// 	} else {
					// 		return
					// 	}
					// })
					// this.packageList = arr
					this.total = res.page_info.page_count;

					this.getRollMessageList();
					uni.stopPullDownRefresh();
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		getPackageListReturnSecond() {
			this.$request(
				'/api/getProductCenter',
				{
					is_upload: 1,
					page_now: this.pageObj.pageNow,
					page_size: this.pageObj.pageSize,
					operator_id: '',
					rebate_type: 2,
					belonging_place: this.packageQueryObj.belongPlace,
					data_quota_min: this.packageQueryObj.trafficLimit.split('-')[0],
					data_quota_max: this.packageQueryObj.trafficLimit.split('-')[1],
					call_duration_min: this.packageQueryObj.callDuration.split('-')[0],
					call_duration_max: this.packageQueryObj.callDuration.split('-')[1],
					// is_choose_number: this.formClassify.is_choose_number, // 可否选号
					first_recharge_amount_min: this.packageQueryObj.firstRechargeAmount ? this.packageQueryObj.firstRechargeAmount.split('-')[0] : '',
					first_recharge_amount_max: this.packageQueryObj.firstRechargeAmount ? this.packageQueryObj.firstRechargeAmount.split('-')[1] : '',
					monthly_rent_min: this.packageQueryObj.monthlyRent ? this.packageQueryObj.monthlyRent.split('-')[0] : '',
					monthly_rent_max: this.packageQueryObj.monthlyRent ? this.packageQueryObj.monthlyRent.split('-')[1] : ''
				},
				'GET'
			).then((res) => {
				if (res.code == 1) {
					res.data.forEach((item) => {
						this.packageList.push(item);
					});

					this.total = res.page_info.page_count;
					this.userToken = uni.getStorageSync('h5-token');
					// this.moveterConfig()
					uni.stopPullDownRefresh();
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取套餐二维码
		getOncePackageShareImg() {
			const timestamp = new Date().getTime();
			let token = uni.getStorageSync('h5-token');
			let isAgent = uni.getStorageSync('h5-isAgent');
			uni.request({
				url: 'https://saler.jkcae.com/app/api/getPackageFxPoster?package_id=' + this.packageId + '&type=' + 1,
				method: 'GET',
				header: {
					Authorization: token,
					Platform: isAgent == 0 ? 2 : 1
				},
				success: (res) => {
					if (res.data.code == 1) {
						uni.hideLoading();
						this.promotionImg = res.data.data + '?v=' + timestamp;
						this.promotionSahreImg = res.data.data;
						this.promotionSahreUrl = res.data.url;
						// this.promotionSahreUrl = '?' + res.data.url
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						});
						return;
					}
				}
			});
		},

		// 弹窗链接
		getOncePackageLink() {
			this.$request(
				'/api/createPackagePoster',
				{
					package_id: this.packageId,
					id: uni.getStorageSync('userInfo').id,
					agent_id: uni.getStorageSync('userInfo').agent_id ? uni.getStorageSync('userInfo').agent_id : ''
				},
				'POST'
			).then((res) => {
				if (res.code == 1) {
					this.packageLink = res.data;
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 点击佣金规则
		// handlerRule(val, index) {
		// 	this.packageList.forEach((item, index1) => {
		// 		this.$set(item, `isShowRulesMask${index1}`, false)
		// 	})
		// 	this.$set(val, `isShowRulesMask${index}`, true)
		// 	this.maskTitle = val.yjzc
		// },

		// handlerFlag(item, index) {
		// 	return item["isShowRulesMask" + index]
		// },

		// 点击服务
		handlerService(val, index) {
			this.pageObj.pageNow = 1;
			this.packageList = [];
			this.isActive = val.operator_id;
			this.packageType = val.operator_id;
			this.hotPackageTitle = val.name;
			if (this.userToken) {
				if (this.isActive == 5) {
					this.getPackageListReturnSecond();
				} else {
					this.getPackageList();
				}
			} else {
				this.getAgentPackageAllNotk();
			}
		},

		// 秒返专区
		handleReturnSeconds(val) {
			uni.navigateTo({
				url: '/pages/index/returnSeconds/returnSeconds?type=' + val
			});
		},

		// 点击联系客服
		handlerCustom() {
			if (this.userToken) {
				this.getAgentKefuInfo();
			} else {
				this.getAgentKefuInfoNoLogin();
			}
		},

		// 获取合伙人客服接口-无登录
		getAgentKefuInfoNoLogin() {
			this.$request('/getAgentKefuInfo', {}, 'GET').then((res) => {
				if (res.code == 1) {
					if (res.data.kefu_type == 1) {
						uni.navigateTo({
							url: '/pages/index/webview/webview?url=' + res.data.kefu_url
						});
					} else if (res.data.kefu_type == 2) {
						this.customObj = res.data.kefu_image;
						this.showCustom = true;
					}
				} else {
					uni.showToast({
						title: '您没有合伙人客服',
						icon: 'none'
					});
					return;
				}
			});
		},

		// 获取合伙人客服接口-登录
		getAgentKefuInfo() {
			this.$request('/api/getAgentKefuInfo', {}, 'GET').then((res) => {
				if (res.code == 1) {
					if (res.data.kefu_type == 1) {
						uni.navigateTo({
							url: '/pages/index/webview/webview?url=' + res.data.kefu_url
						});
					} else if (res.data.kefu_type == 2) {
						this.customObj = res.data.kefu_image;
						this.showCustom = true;
					}
				} else {
					uni.showToast({
						title: '您没有合伙人客服',
						icon: 'none'
					});
					return;
				}
			});
		},

		handleShowAge(item, index) {
			// if (!this.isShowAge) {
			// 	this.isShowAge = item.id
			// } else {
			// 	this.isShowAge = null
			// }
			this.knowledgeId = item.id;
			this.getPackageKnowledge();
		},

		// 用户授权手机号注册接口
		xcxUserLogin(val) {
			const that = this;
			this.$request(
				'/xcxUserLogin',
				{
					code: val.code
				},
				'GET'
			).then((res) => {
				if (res.code == 1) {
					uni.setStorageSync('h5-token', res.data.token);
					uni.setStorageSync('userInfo', res.data.userInfo);
					// that.userTokenNew = uni.getStorageSync('h5-token')
					uni.login({
						provider: 'weixin', //使用微信登录
						success: function (loginRes) {
							that.xcxGetUserInfo(loginRes.code, res.data.userInfo.phone);
						}
					});
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 微信登录接口-code
		xcxGetUserInfo(val, phone) {
			const that = this;
			this.$request(
				'/xcxGetUserInfo',
				{
					code: val,
					phone: phone,
					is_agent: uni.getStorageSync('h5-isAgent') == 1 ? 1 : 0
				},
				'GET'
			).then((res) => {
				uni.setStorageSync('userWxOpenid', res.data);
				that.getPackageList();
				that.userWxOpenidNew = uni.getStorageSync('userWxOpenid');
				that.userTokenNew = uni.getStorageSync('h5-token');
				that.userToken = uni.getStorageSync('h5-token');
			});
		},

		// 用户手机号授权
		onGetPhoneNumber(e) {
			if ((e.detail.errMsg = 'getPhoneNumber:ok')) {
				this.xcxUserLogin(e.detail);
			} else {
				return;
			}
		},

		// 点击套餐
		handlerPackage(val) {
			const that = this;
			this.packageId = val.id;
			this.packageDetailObj = val;
			this.getFxuserIsFollow();
			// uni.navigateTo({
			// 	url: '/pages/quertDetail/quertDetail?package_id=' + val.id + '&agent_id=' + val.agent_id
			// })
			// return
			// this.getFxuserIsSubscribe(val)

			// if (!uni.getStorageSync('h5-token')) {} else {
			// 	this.getFxuserIsSubscribe(val)
			// 	if (this.isFollow == false) {
			// 		that.showOfficialAccount = true
			// 	} else {
			// 		uni.showLoading({
			// 			title: '正在加载中'
			// 		})
			// 		this.packageId = val.id
			// 		this.packageDetailObj = val
			// 		// this.getOncePackageLink()
			// 		this.getOncePackageShareImg()
			// 		this.showPopupShare = true
			// 	}
			// }
			// this.promotionImg = ''
			// if (!uni.getStorageSync('h5-token')) {
			// 	uni.showToast({
			// 		title: '请先登录',
			// 		icon: 'none',
			// 		success: res => {
			// 			setTimeout(() => {
			// 				uni.navigateTo({
			// 					url: '/pages/login/login'
			// 				})
			// 			}, 1200)
			// 		}
			// 	})
			// } else {
			// 	uni.showLoading({
			// 		title: '正在加载中'
			// 	})
			// 	this.packageId = val.id
			// 	this.packageDetailObj = val
			// 	this.share.title = val.name
			// 	this.share.imageUrl = val.cover_img
			// 	// this.getOncePackageLink()
			// 	this.getOncePackageShareImg()
			// 	this.showPopupShare = true
			// }
		},

		// 弹窗-查看商品详情
		handlerDetail() {
			uni.navigateTo({
				url: '/pages/index/packageDetail/packageDetail?id=' + this.packageId
			});
		},

		// 弹窗-复制
		handlerCopy() {
			uni.setClipboardData({
				data: this.packageLink,
				success: (res) => {
					uni.showToast({
						title: '复制成功',
						icon: 'none'
					});
				}
			});
		},

		// 点击查号关闭弹窗
		handlerCancel() {
			this.showPopup = false;
		},

		// 点击查号关闭二维码弹窗
		handlerCancelShare() {
			this.showPopupShare = false;
		},

		// 生成专属海报
		handlerGenerate() {
			this.getOncePackageShareImg();
		},

		// 点击遮罩层
		handlerMask() {
			this.showPopup = false;
		},

		// 获取靓号链接
		getPrettyNumShareUrl() {
			let isAgent = uni.getStorageSync('h5-isAgent');
			this.$request(
				'/api/getPrettyNumShareUrl',
				{
					user_id: uni.getStorageSync('userInfo').id,
					platform: isAgent == 0 ? 2 : 1
				},
				'POST'
			).then((res) => {
				if (res.code == 1) {
					this.beautifulNum = res.data;
				} else {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					return;
				}
			});
		},

		// 产品选择
		handleChooseTab(val) {
			if (val.name == '靓号产品') {
				let isAgent = uni.getStorageSync('h5-isAgent');
				if (isAgent == 0) {
					this.partnerReminder = `
									<p>1. 您的靓号佣金可在“订单-靓号订单”中单独查看；</p>
									<p>2. 结算规则：号码库中的免费号码均考核次月在网，联通号码追加考核首充50，佣金于次月底结算。</p>
							`;
				} else {
					this.partnerReminder = `
								<p>您的靓号佣金可在“订单-靓号订单”中单独查看：</p>
								<p>1. 0元免费靓号，佣金45元以上，因号码不同而异</p>
								<p>2. 有价靓号（≥1000元），佣金为售价的10%左右，因号码不同而异</p>
								<p>3. 结算规则：号码库中的免费号码均考核次月在网，联通号码追加考核首充50，佣金于次月底结算。</p>
						`;
				}
				this.showBeautifulPopup = true;
			} else if (val.name == '随身WIFI') {
				uni.showLoading({
					title: '生成海报中'
				});
				this.getWifiPoster();
				this.$refs.refWiFiShare.isShowWifiShare = true;
			} else if (val.name == '宽带产品') {
				uni.showLoading({
					title: '生成海报中'
				});
				this.getBroadbandPoster();
				this.$refs.refBroadbandShare.isShobroadbandiShare = true;
				// uni.showToast({
				// 	title: '正在开发中',
				// 	icon: 'none'
				// });
				// return;
			}
		},
		// 关闭宽带产品弹窗
		handleClosebroadbandShare() {
			uni.hideLoading();
			this.$refs.refBroadbandShare.isShobroadbandiShare = false;
		},

		// 我已知晓
		handleKnow() {
			this.showBeautifulPopup = false;
			this.getPrettyNumShareUrl();
			this.$refs.refBeautifulNumber.showBeautifulNumber = true;
		}
	}
};
</script>

<style lang="scss" scoped>
.home_container {
	padding: 16rpx 20rpx;

	.name_phone_box {
		width: 100%;

		.name_phone_img {
			width: 100%;
		}
	}

	.home_service_box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 22rpx 28rpx 15rpx;

		.service_product_box {
			display: flex;
			flex-direction: column;
			align-items: center;

			.product_img_box {
				width: 68rpx;
				height: 68rpx;

				.product_img {
					width: 100%;
					height: 100%;
				}
			}

			.product_title {
				font-size: 26rpx;
				font-family: all-font;
				font-weight: 400;
				color: #333;
			}
		}

		.service_product_box_active {
			display: flex;
			flex-direction: column;
			align-items: center;

			.product_img_box {
				width: 68rpx;
				height: 68rpx;

				.product_img {
					width: 100%;
					height: 100%;
				}
			}

			.product_title {
				font-size: 26rpx;
				font-family: all-font;
				font-weight: 400;
				color: #4f96ff;
			}
		}

		.service_custom_box {
			display: flex;
			flex-direction: column;
			align-items: center;

			.custom_img_box {
				width: 68rpx;
				height: 68rpx;

				.custom_img {
					width: 100%;
					height: 100%;
				}
			}

			.custom_title {
				font-size: 26rpx;
				font-weight: 400;
				color: #333;
				padding-top: 8rpx;
			}
		}
	}

	.hot_package_box {
		display: flex;
		align-items: center;
		padding: 0 0 28rpx;

		.hot_package_line {
			width: 9rpx;
			height: 33rpx;
			background: #4f96ff;
			box-shadow: 0px 0px 8rpx 0px rgba(242, 242, 242, 0.36);
			border-radius: 5rpx;
		}

		.hot_package_title {
			font-family: all-font;
			font-weight: 500;
			font-size: 34rpx;
			color: #262626;
			padding-left: 33rpx;
		}
	}

	.return_seconds_box {
		width: 100%;
		margin-top: -10rpx;

		.return_seconds_img {
			width: 100%;
		}
	}

	.package_query_box {
		display: flex;
		justify-content: space-between;
		background: #ffffff;
		box-shadow: 0px 5rpx 8rpx 1px #ececec;
		border-radius: 12rpx;
		border: 1px solid #fafafa;
		padding: 25rpx 33rpx 25rpx 28rpx;
		margin-bottom: 11rpx;

		.package_query_all {
			display: flex;

			.package_query_name {
				font-family: all-font;
				font-weight: 400;
				font-size: 28rpx;
				color: #666666;
				padding-right: 11rpx;
			}

			.package_query_img {
				width: 20rpx;
				height: 12rpx;

				.query_img {
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.home_package_box {
		position: relative;
		background: #ffffff;
		box-shadow: 0px 6rpx 6rpx 1px #ececec;
		border-radius: 16rpx;
		border: 1px solid #f5f5f5;
		margin-bottom: 12rpx;
		padding: 25rpx 0 18rpx 22rpx;

		.home_package_all {
			display: flex;

			.package_top_img {
				position: absolute;
				top: 0;
				left: 22rpx;
				width: 44rpx;
				height: 61rpx;
				z-index: 998;

				.top_img {
					width: 100%;
					height: 100%;
				}
			}

			.package_all_box {
				width: 224rpx;
				height: 237rpx;
				margin-right: 40rpx;

				.package_all_img {
					width: 100%;
					height: 100%;
				}
			}

			.package_all_con {
				width: 375rpx;

				.package_title {
					font-family: all-font;
					font-weight: bold;
					font-size: 32rpx;
					color: #1a1a1a;
				}

				.pacakge_tip_box {
					display: flex;
					flex-wrap: wrap;
					padding-top: 10rpx;

					.pacakge_tip_all {
						font-family: all-font;
						padding: 0 6rpx;
						border-radius: 6rpx;
						margin: 0 6rpx 6rpx 0;
					}

					.package_tip_free {
						background: #ffe8d6;
						color: #ff7b0c;
						font-size: 24rpx;
						padding: 3rpx 4rpx;
						margin-right: 20rpx;
					}

					.package_tip_official {
						background: #e4ffe8;
						color: #2fc247;
						font-size: 24rpx;
						padding: 3rpx 4rpx;
					}
				}

				.package_tip {
					font-family: all-font;
					font-weight: 400;
					font-size: 24rpx;
					color: #808080;
					margin: 16rpx 0;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}

				.package_flow_box {
					display: flex;
					align-items: center;

					.package_flow {
						display: flex;
						flex-direction: column;
						align-items: center;

						.flow_title {
							font-family: my-font;
							font-weight: bold;
							font-size: 29rpx;
							color: #262626;
						}

						.flow_name {
							font-family: all-font;
							font-weight: 400;
							font-size: 24rpx;
							color: #808080;
						}
					}

					.flow_line {
						width: 2rpx;
						height: 31rpx;
						background: #e61b15;
						border: 2rpx solid #e6e6e6;
						margin: 0 28rpx;
					}
				}

				.package_commission {
					font-family: all-font;
					font-weight: 500;
					font-size: 26rpx;
					color: #f4281d;
					padding-top: 25rpx;
				}

				.package_btn_box {
					display: flex;
					justify-content: flex-end;

					.package_btn_phone {
						display: flex;
						justify-content: center;
						align-items: center;
						height: 53rpx;
						background: linear-gradient(143deg, #fb8377, #f4271c);
						box-shadow: 0px 4rpx 2rpx 0px rgba(255, 195, 192, 0.74);
						border-radius: 27rpx;
						font-family: all-font;
						font-weight: 500;
						font-size: 27rpx;
						color: #ffffff;
					}

					.package_btn {
						display: flex;
						justify-content: center;
						align-items: center;
						width: 155rpx;
						height: 53rpx;
						background: linear-gradient(143deg, #fb8377, #f4271c);
						box-shadow: 0px 4rpx 2rpx 0px rgba(255, 195, 192, 0.74);
						border-radius: 27rpx;
						font-family: all-font;
						font-weight: 500;
						font-size: 27rpx;
						color: #ffffff;
					}
				}
			}
		}

		.package_bottom_box {
			.package_tip {
				font-family: all-font;
				font-weight: 400;
				font-size: 26rpx;
				color: #333;
				line-height: 38rpx;
				padding: 37rpx 30rpx 25rpx 0;
			}

			.package_commission {
				font-family: all-font;
				font-weight: 550;
				font-size: 29rpx;
				color: #f4281d;
			}

			.package_btn_box {
				margin-right: 20rpx;

				.package_btn_phone {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 160rpx;
					height: 53rpx;
					background: linear-gradient(143deg, #fb8377, #f4271c);
					box-shadow: 0px 4rpx 2rpx 0px rgba(255, 195, 192, 0.74);
					border-radius: 27rpx;
					font-family: all-font;
					font-weight: 500;
					font-size: 27rpx;
					color: #ffffff;
				}

				.package_btn {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 155rpx;
					height: 53rpx;
					background: linear-gradient(143deg, #fb8377, #f4271c);
					box-shadow: 0px 4rpx 2rpx 0px rgba(255, 195, 192, 0.74);
					border-radius: 27rpx;
					font-family: all-font;
					font-weight: 500;
					font-size: 27rpx;
					color: #ffffff;
				}
			}
		}

		.home_package_other {
			padding-top: 16rpx;
			margin-top: 26rpx;
			border-top: 1px solid #f5f5f5;

			.handle_age_box:last-child {
				padding-bottom: 0;
			}

			.handle_age_box {
				display: flex;
				padding-bottom: 17rpx;

				.age_icon_box {
					width: 26rpx;
					height: 26rpx;
					margin-right: 15rpx;

					.age_icon {
						width: 100%;
						height: 100%;
					}
				}

				.age_title {
					width: 632rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					font-size: 22rpx;
					color: #666666;
				}
			}
		}
	}

	.bottom_box {
		color: #ccc;
		text-align: center;
		padding: 20rpx 0;
	}

	.popup_official_box {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.popup_detail_img_box {
		.popup_detail_img_all {
			width: 100%;

			.popup_detail_img {
				width: 100%;
			}
		}

		.popup_detail_msg {
			padding: 60rpx 40rpx 46rpx;

			.popup_detail_msg_box {
				.popup_detail_title {
					font-family: Source Han Sans CN;
					font-weight: 550;
					font-size: 34rpx;
					color: #333333;
					padding-bottom: 20rpx;
				}

				.popup_detail_content {
					font-family: Source Han Sans CN;
					font-weight: 300;
					font-size: 30rpx;
					line-height: 40rpx;
					color: #333;
				}
			}
		}
	}

	.beautiful_popup_box {
		padding: 40rpx 30rpx 30rpx;

		.beautiful_title {
			font-family: screen-font;
			font-weight: 500;
			font-size: 32rpx;
			color: #1a1a1a;
			text-align: center;
			padding-bottom: 30rpx;
		}

		.beautiful_content {
			font-size: 28rpx;
		}

		.beautiful_btn {
			display: flex;
			align-items: center;
			justify-content: center;
			height: 79rpx;
			background: #0e255b;
			border-radius: 14rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 30rpx;
			color: #ffd79a;
			margin-top: 56rpx;
		}
	}

	.popup_official_title {
		text-align: center;
		padding-bottom: 20rpx;
	}

	/* 遮罩层*/
	.mask {
		background-color: rgba(0, 0, 0, 0.7);
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0;
	}

	.popup_share_box {
		.share_img_box {
			width: 550rpx;
			height: 930rpx;

			.share_img {
				width: 100%;
				height: 100%;
				border-radius: 12rpx;
				-webkit-touch-callout: default; // 要配置这行关键代码，不然可能不生效
			}
		}

		.share_btn_box {
			display: flex;
			justify-content: space-evenly;
			padding: 16rpx 0;

			.share_btn_all {
				display: flex;
				flex-direction: column;
				align-items: center;

				.share_btn_img {
					width: 72rpx;
					height: 72rpx;

					.btn_img {
						width: 100%;
						height: 100%;
					}
				}

				.share_btn_title {
					font-family: all-font;
					font-weight: 500;
					font-size: 28rpx;
					color: #333333;
					padding-top: 6rpx;
				}
			}
		}
	}

	.popup_notify_all {
		margin: 0 20rpx;

		.popup_notify_box {
		}
	}

	.classify_img_box {
		.classify_img {
			width: 120rpx;
			height: 120rpx;
		}
	}

	.custom_img_box {
		.custom_img {
			width: 120rpx;
			height: 120rpx;
		}
	}

	::v-deep .u-drawer {
		z-index: 999 !important;
	}

	.classify_popup_box {
		// width: 700rpx;
		// background: #f6f6f6;
		padding: 40rpx 50rpx 50rpx;

		.classify_popup_title {
			font-family: Source Han Sans CN;
			font-weight: 500;
			font-size: 34rpx;
			text-align: center;
			color: #333333;
		}

		.classify_title {
			padding: 20rpx 0;
		}

		.classify_popup_input {
			width: 594rpx;
			background: #fafafa;
			border-radius: 8rpx;
			border: 1px solid #f0f0f0;
			padding-left: 15rpx;
			padding-right: 15rpx;
		}

		.select_box {
			width: 594rpx;
			background: #fafafa;
			border-radius: 8rpx;
			border: 1px solid #f0f0f0;
			padding-left: 15rpx;
			padding-right: 15rpx;
		}

		.classify_btn_box {
			display: flex;
			justify-content: center;
			padding-top: 30rpx;

			.classify_reset_btn {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 250rpx;
				height: 66rpx;
				background: #f6f6f6;
				border-radius: 32rpx 0px 0px 32rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 28rpx;
				color: #808080;
			}

			.classify_sure_btn {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 250rpx;
				height: 66rpx;
				background: #3984fa;
				border-radius: 0px 32rpx 32rpx 0px;
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 28rpx;
				color: #ffffff;
			}
		}
	}

	.popup_custom_box {
		width: 100%;
	}

	.popup_name_box {
		padding: 20rpx 20rpx;

		.popup_name_title {
			font-size: 36rpx;
			font-weight: 550;
			color: #007aff;
			text-align: center;
			padding-bottom: 40rpx;
		}

		.popup_option_title {
			font-size: 32rpx;
			color: #000;
			padding-bottom: 20rpx;
		}

		.popup_option_con {
			color: #999;
			font-size: 30rpx;
			padding: 0 0 30rpx 30rpx;
		}
	}

	.popup_box {
	}
}
</style>
